#pragma once

#include "OpaqueAction.h"

#include "InputPin.h"
#include "OutputPin.h"

namespace uml {

OpaqueAction::OpaqueAction(const QString& umlType)
    : Action(umlType) {}

void OpaqueAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Action::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(bodys_, "bodys", json, errorList);
    JsonSerializable::fromJsonArray(inputValues_, "inputValues", json, errorList);
    JsonSerializable::fromJsonArray(languages_, "languages", json, errorList);
    JsonSerializable::fromJsonArray(outputValues_, "outputValues", json, errorList);
}

void OpaqueAction::toJson(QJsonObject& json) {
    Action::toJson(json);
    JsonSerializable::toJsonArray(bodys_, "bodys", json);
    JsonSerializable::toJsonArray(inputValues_, "inputValues", json);
    JsonSerializable::toJsonArray(languages_, "languages", json);
    JsonSerializable::toJsonArray(outputValues_, "outputValues", json);
}

/// <summary>
/// bodys getter
/// Provides a textual specification of the functionality of the Action, in one or
/// more languages other than UML.
/// </summary>
vector<QString>& OpaqueAction::bodys() {
    return bodys_;
}

/// <summary>
/// inputValues getter
/// The InputPins providing inputs to the OpaqueAction.
/// </summary>
vector<shared_ptr<InputPin>>& OpaqueAction::inputValues() {
    return inputValues_;
}

/// <summary>
/// languages getter
/// If provided, a specification of the language used for each of the body Strings.
/// </summary>
vector<QString>& OpaqueAction::languages() {
    return languages_;
}

/// <summary>
/// outputValues getter
/// The OutputPins on which the OpaqueAction provides outputs.
/// </summary>
vector<shared_ptr<OutputPin>>& OpaqueAction::outputValues() {
    return outputValues_;
}

} // namespace uml
